Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2D multi-ion GLM-MHD equations for the TreeMesh solver #2196

Merged
merged 27 commits into from
Dec 11, 2024

Conversation

amrueda
Copy link
Contributor

@amrueda amrueda commented Dec 9, 2024

This PR introduces a minimal implementation of the 2D multi-ion GLM-MHD equations, designed to work with the TreeMesh solver. It includes a subset of the code from the larger PR that implements the multi-ion GLM-MHD equations (#1427).

@amrueda amrueda marked this pull request as draft December 9, 2024 20:15
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 99.29701% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.43%. Comparing base (f45455b) to head (d26713e).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/equations/equations.jl 50.00% 2 Missing ⚠️
src/equations/ideal_glm_mhd_multiion_2d.jl 99.53% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2196      +/-   ##
==========================================
+ Coverage   96.39%   96.43%   +0.04%     
==========================================
  Files         483      485       +2     
  Lines       38349    38918     +569     
==========================================
+ Hits        36964    37529     +565     
- Misses       1385     1389       +4     
Flag Coverage Δ
unittests 96.43% <99.30%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DanielDoehring DanielDoehring changed the title WIP: Add 2D GLM-MHD equations for the TreeMesh solver WIP: Add 2D multi-ion GLM-MultiIon-MHD equations for the TreeMesh solver Dec 10, 2024
@amrueda
Copy link
Contributor Author

amrueda commented Dec 10, 2024

The old performance issues have been resolved. For comparison, the performance indices on a single core of an AMD Ryzen Threadripper 3990X for the test examples/tree_2d_dgsem/elixir_mhdmultiion_ec.jl, which has 2 ion species and 14 equations, are about

time/DOF/rhs!:  6.64871945e-07 s, and `PID:            6.89436731e-07 s

These performance indices are comparable with the performance indices of the single-fluid MHD test ‘examples/tree_2d_dgsem/elixir_mhd_ec.jl‘:

time/DOF/rhs!:  1.50055863e-07 s, and PID:            1.66041059e-07 s

Here is the summary at the end of the 2-ion simulation:

────────────────────────────────────────────────────────────────────────────────────
             Trixi.jl                      Time                    Allocations      
                                  ───────────────────────   ────────────────────────
        Tot / % measured:              1.44s /  98.8%           34.5MiB /  98.0%    

Section                   ncalls     time    %tot     avg     alloc    %tot      avg
────────────────────────────────────────────────────────────────────────────────────
rhs!                         491    1.32s   92.8%  2.69ms   9.33KiB    0.0%    19.5B
  volume integral            491    1.06s   74.6%  2.16ms     0.00B    0.0%    0.00B
  interface flux             491    177ms   12.4%   360μs     0.00B    0.0%    0.00B
  source terms               491   43.5ms    3.1%  88.6μs     0.00B    0.0%    0.00B
  surface integral           491   17.5ms    1.2%  35.6μs     0.00B    0.0%    0.00B
  prolong2interfaces         491   14.3ms    1.0%  29.1μs     0.00B    0.0%    0.00B
  Jacobian                   491   3.59ms    0.3%  7.31μs     0.00B    0.0%    0.00B
  reset ∂u/∂t                491   2.89ms    0.2%  5.89μs     0.00B    0.0%    0.00B
  ~rhs!~                     491    538μs    0.0%  1.10μs   9.33KiB    0.0%    19.5B
  prolong2boundaries         491   24.6μs    0.0%  50.0ns     0.00B    0.0%    0.00B
  prolong2mortars            491   20.7μs    0.0%  42.2ns     0.00B    0.0%    0.00B
  mortar flux                491   18.9μs    0.0%  38.5ns     0.00B    0.0%    0.00B
  boundary flux              491   11.2μs    0.0%  22.7ns     0.00B    0.0%    0.00B
analyze solution              11   55.2ms    3.9%  5.02ms   27.0MiB   79.6%  2.45MiB
calculate dt                  99   33.3ms    2.3%   336μs     0.00B    0.0%    0.00B
I/O                            6   13.6ms    1.0%  2.27ms   6.88MiB   20.3%  1.15MiB
  save solution                5   12.7ms    0.9%  2.54ms   6.84MiB   20.2%  1.37MiB
  ~I/O~                        6    899μs    0.1%   150μs   34.1KiB    0.1%  5.69KiB
  get element variables        5   2.00μs    0.0%   400ns     0.00B    0.0%    0.00B
  save mesh                    5   1.28μs    0.0%   256ns     0.00B    0.0%    0.00B
  get node variables           5    220ns    0.0%  44.0ns     0.00B    0.0%    0.00B
────────────────────────────────────────────────────────────────────────────────────

@amrueda amrueda changed the title WIP: Add 2D multi-ion GLM-MultiIon-MHD equations for the TreeMesh solver Add 2D multi-ion GLM-MultiIon-MHD equations for the TreeMesh solver Dec 10, 2024
@amrueda amrueda marked this pull request as ready for review December 10, 2024 12:09
@amrueda amrueda changed the title Add 2D multi-ion GLM-MultiIon-MHD equations for the TreeMesh solver Add 2D multi-ion GLM-MHD equations for the TreeMesh solver Dec 10, 2024
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work 😊

examples/tree_2d_dgsem/elixir_mhdmultiion_ec+llf.jl Outdated Show resolved Hide resolved
test/test_tree_2d_mhdmultiion.jl Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
@amrueda amrueda requested a review from sloede December 10, 2024 16:43
…uations from ideal_glm_mhd_multiion_2d.jl into ideal_glm_mhd_multiion.jl
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small things I only noticed now

src/equations/ideal_glm_mhd_multiion.jl Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
test/test_tree_2d_mhdmultiion.jl Outdated Show resolved Hide resolved
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add some unit tests for type stability in https://github.com/trixi-framework/Trixi.jl/blob/main/test/test_type.jl

examples/tree_2d_dgsem/elixir_mhdmultiion_ec.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small suggestions - otherwise LGTM and can be merged once also Hendrik approves

src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
amrueda and others added 2 commits December 11, 2024 13:22
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
@amrueda
Copy link
Contributor Author

amrueda commented Dec 11, 2024

Please also add some unit tests for type stability in https://github.com/trixi-framework/Trixi.jl/blob/main/test/test_type.jl

Many thanks for the speedy reviews @sloede, @ranocha, @DanielDoehring !! 🙂

I have added unit tests for type stability in 79b0e29.

@amrueda amrueda requested a review from ranocha December 11, 2024 14:31
ranocha
ranocha previously approved these changes Dec 11, 2024
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@amrueda amrueda enabled auto-merge (squash) December 11, 2024 16:05
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor code cleanup opportunity I noted just now.

src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
src/equations/ideal_glm_mhd_multiion_2d.jl Outdated Show resolved Hide resolved
@sloede sloede disabled auto-merge December 11, 2024 18:27
@sloede sloede merged commit 1488a74 into main Dec 11, 2024
40 checks passed
@sloede sloede deleted the arr/multi-ion_mhd_2d branch December 11, 2024 18:28
@JoshuaLampert
Copy link
Member

@sloede there were some (admittedly minor) unresolved conversations (three comments from me and one comment from Hendrik).

@amrueda
Copy link
Contributor Author

amrueda commented Dec 12, 2024

@sloede there were some (admittedly minor) unresolved conversations (three comments from me and one comment from Hendrik).

I have implemented the minor suggestions that were blocking the merge of this (already approved) PR in the commit 8af2059 of my new PR #2204.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants